package com.kara.woodAgent.agent.memory;

import com.kara.woodAgent.agent.model.ModelProvider;

import dev.langchain4j.data.document.Metadata;
import dev.langchain4j.data.embedding.Embedding;
import dev.langchain4j.data.segment.TextSegment;
import dev.langchain4j.model.embedding.EmbeddingModel;
import dev.langchain4j.model.output.Response;
import dev.langchain4j.rag.content.Content;
import dev.langchain4j.rag.content.retriever.ContentRetriever;
import dev.langchain4j.rag.content.retriever.EmbeddingStoreContentRetriever;
import dev.langchain4j.store.embedding.EmbeddingStore;
import jakarta.annotation.PostConstruct;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.Map;

/**
 * @author tzy
 * @version 1.0
 * @project wood_agent
 * @description
 * @date 2025/6/9 14:52:38
 */
@Component
public class MemoryStore {

	@Autowired
	private EmbeddingStoreProvider embeddingStoreProvider;

	@Autowired
	private ModelProvider modelProvider;


	@PostConstruct
	public void init() {
//		EmbeddingStore<TextSegment>  embeddingStore = embeddingStoreProvider.getEmbeddingStore();
//		EmbeddingModel embeddingModel = modelProvider.getEmbeddingModel();

	}


	public List<Content>  query(){

//		ContentRetriever contentRetriever = EmbeddingStoreContentRetriever.builder()
//				.embeddingStore(embeddingStore)
//				.embeddingModel(embeddingModel)
//				.maxResults(3);
		return null;

	}

	public void save(){

		EmbeddingStore<TextSegment> embeddingStore = embeddingStoreProvider.getEmbeddingStore();


		EmbeddingModel embeddingModel = modelProvider.getEmbeddingModel();

		Response<Embedding> embed = embeddingModel.embed("");

		Response<List<Embedding>> listResponse = embeddingModel.embedAll(List.of(TextSegment.textSegment("")));

		Embedding content = embed.content();

		Map<String, Object> metadata = embed.metadata();

		TextSegment textSegment = TextSegment.textSegment("", Metadata.metadata("a", "b"));



	}

}
